import { RouteRecordRaw } from 'vue-router';
import { Layout, ParentLayout } from '@/router/constant';
import { IconCommon } from '@arco-design/web-vue/es/icon';
import { renderIcon } from '@/utils';

/**
 * @param name 路由名称, 必须设置,且不能重名
 * @param meta 路由元信息（路由附带扩展信息）
 * @param redirect 重定向地址, 访问这个路由时,自定进行重定向
 * @param meta.disabled 禁用整个菜单
 * @param meta.title 菜单名称
 * @param meta.icon 菜单图标
 * @param meta.keepAlive 缓存该路由
 * @param meta.sort 排序越小越排前
 *
 * */
const routes: Array<RouteRecordRaw> = [
  {
    path: '/comp',
    name: 'Comp',
    component: Layout,
    redirect: '/comp/table',
    meta: {
      title: '组件示例',
      icon: renderIcon(IconCommon),
      sort: 8,
    },
    children: [
      {
        path: 'table',
        name: 'CompTable',
        redirect: '/comp/table/basic',
        component: ParentLayout,
        meta: {
          title: '表格',
        },
        children: [
          {
            path: 'basic',
            name: `CompTableBasic`,
            meta: {
              title: '基础表格',
            },
            component: () => import('@/views/comp/table/basic.vue'),
          },
          {
            path: 'editCell',
            name: 'CompTableEditCell',
            meta: {
              title: '单元格编辑',
            },
            component: () => import('@/views/comp/table/editCell.vue'),
          },
          {
            path: 'editRow',
            name: 'CompTableEditRow',
            meta: {
              title: '整行编辑',
            },
            component: () => import('@/views/comp/table/editRow.vue'),
          },
        ],
      },
      {
        path: 'form',
        name: 'CompForm',
        redirect: '/comp/form/basic',
        component: ParentLayout,
        meta: {
          title: '表单',
        },
        children: [
          {
            path: 'basic',
            name: 'CompFormBasic',
            meta: {
              title: '基础使用',
            },
            component: () => import('@/views/comp/form/basic.vue'),
          },
          {
            path: 'fullForm',
            name: 'CompFullForm',
            meta: {
              title: '完整表单',
            },
            component: () => import('@/views/comp/form/fullForm.vue'),
          },
          {
            path: 'useForm',
            name: 'CompUseForm',
            meta: {
              title: 'useForm',
            },
            component: () => import('@/views/comp/form/useForm.vue'),
          },
        ],
      },
      {
        path: 'upload',
        name: 'CompUpload',
        meta: {
          title: '上传图片',
        },
        component: () => import('@/views/comp/upload/index.vue'),
      },
      {
        path: 'modal',
        name: 'CompModal',
        meta: {
          title: '弹窗扩展',
        },
        component: () => import('@/views/comp/modal/index.vue'),
      },
      {
        path: 'richtext',
        name: `Richtext`,
        meta: {
          title: '富文本',
        },
        component: () => import('@/views/comp/richtext/vue-quill.vue'),
      },
      {
        path: 'drag',
        name: `Drag`,
        meta: {
          title: '拖拽',
        },
        component: () => import('@/views/comp/drag/index.vue'),
      },
      {
        path: 'region',
        name: `Region`,
        meta: {
          title: '地区',
        },
        component: () => import('@/views/comp/region/index.vue'),
      },
      {
        path: 'cropper',
        name: `Cropper`,
        meta: {
          title: '图片裁剪',
        },
        component: () => import('@/views/comp/cropper/index.vue'),
      },
      {
        path: 'qrcode',
        name: `Qrcode`,
        meta: {
          title: '二维码',
        },
        component: () => import('@/views/comp/qrcode/index.vue'),
      },
      {
        path: 'password',
        name: `Password`,
        meta: {
          title: '密码强度',
        },
        component: () => import('@/views/comp/password/index.vue'),
      },
      {
        path: 'select',
        name: `Select`,
        meta: {
          title: '选择器',
        },
        component: () => import('@/views/comp/select/BasicSelect.vue'),
      },
      {
        path: 'tableselect',
        name: `TableSelect`,
        meta: {
          title: '表格选择器',
        },
        component: () => import('@/views/comp/tableSelect/tableSelect.vue'),
      },
    ],
  },
];

export default routes;
